<?php


class StructTable extends Doctrine_Table
{

	public static function getInstance()
	{
		return Doctrine_Core::getTable('Struct');
	}

	public static function queryWithRelsByIdAnnoset($id)
	{
		return self::getInstance()->createQuery("s INDEXBY s.id")->leftJoin("s.Rels r")
				->where("s.id_annoset = ?", $id);
	}

	public static function getLayers($id){
		return self::getInstance()->createQuery('s')->select('s.list_type')
				->where('s.id_annoset = ?', $id)->addWhere('s.list_type != ?', 'annoSet')
				->groupBy('s.list_type ASC');
	}
	
	public static function getMaxId(){
		$record =  self::getInstance()->createQuery('s')->select('max(s.id)')->execute();
		return $record[0]->getMax();
	}
}
